<?php

namespace App\Http\Controllers\Web;

use App\ConstDir\ErrorConst;
use App\Repository\Models\ShopType;
use App\Repository\Repositories\Interfaces\ShopRepository;

 
class ShopController extends BaseController
{
    
    protected $shop_repo;
    public function __construct(ShopRepository $shop_repo )
    {
        $this->shop_repo = $shop_repo;
    }

    public function index()
    {
        $shops = $this->shop_repo->with('user')->with('companyMaterial')->with('company')->with('shopLevel')->paginate($this->perPage);
        
        foreach($shops['data'] as $k=> $v){
            
            $shops['data'][$k]['sp_type_id_arr']=explode(",",$v['sp_type_id']);
            foreach($shops['data'][$k]['sp_type_id_arr'] as $key=>$val){
                $shops['data'][$k]['sp_type_id_type'][]= ShopType::query()->find($val);
            }
            
        }
        
        return $this->success(ErrorConst::SUCCESS_CODE_MSG, $shops, true);
    }


    public function show($id)
    {
        
    }



}
